import { Boot } from '@wangeditor/editor'

class MyButtonMenu {
  title = '源码'
  tag = 'button'
  alwaysEnable = true

  isActive (editor) {
    return editor?.isSourceMode || false
  }

  getValue () {
    return ''
  }

  isDisabled () {
    return false
  }

  exec (editor) {
    editor.isSourceMode = !editor?.isSourceMode
    editor.emit('sourceMode', editor?.isSourceMode)
  }
}

// 定义菜单配置
export const menuSource = {
  key: 'html-source',
  factory () {
    return new MyButtonMenu()
  }
}

Boot.registerMenu(menuSource)
